{include file="public/header" /}

<div class="page">
    <div class="fixed-bar">
        <div class="item-title">
            <div class="subject">
                <h3>{$Think.lang.ds_wholesale}</h3>
                <h5></h5>
            </div>
            {include file="public/admin_items" /}
        </div>
    </div>
    <div class="homepage-focus" dstype="editStoreContent">
        <ul class="tab-menu">
            <li class="current">{$Think.lang.store_info}</li>
        </ul>
        <form id="joinin_form" enctype="multipart/form-data" method="post"
            action="{:url('Wholesale/update_save_joinin')}" style="display:none;">
            <input type="hidden" name="member_id" value="" />

            <table border="0" cellpadding="0" cellspacing="0" class="store-joinin ds-default-table">
                <thead>
                    <tr>
                        <th colspan="2">系统账号信息：</th>
                    </tr>
                </thead>
                <tbody>
                    <tr>
                        <th class="w150">{$Think.lang.merchant_account}：</th>
                        <td class="item-text">
                            <input type="text" id="member_name" name="member_name" class="w300"
                                placeholder={$Think.lang.login_register_username_to_login} />
                        </td>
                    </tr>


                    <tr>
                        <th class="w150">{$Think.lang.merchant_pwd}：</th>
                        <td><input id="merchant_pwd" name="member_password" type="text" class="w300" />
                            <span></span>
                            <p style="color: #777;
    clear: both;
    margin-top: 10px;font-size: 0.8em;color: #F30" class="emphasis">{$Think.lang.merchant_pwd1}</p>
                        </td>
                    </tr>
                </tbody>
            </table>

            <!--运营商经营信息-->
            <table border="0" cellpadding="0" cellspacing="0" class="store-joinin ds-default-table">
                <thead>
                    <tr>
                        <th colspan="2">供货商经营信息：</th>
                    </tr>
                </thead>
                <tbody>

                    <tr>
                        <th class="w150">{$Think.lang.store_type}：</th>
                        <td class="item-text">
                            <select name="store_type" id="store_type">
                                <option value="0">请选择</option>
                                {notempty name="class_list"}
                                {foreach $class_list as $key => $val}
                                <option value="{$val['storeclass_id']}">{$val['storeclass_name']}</option>
                                {/foreach}
                                {/notempty}
                            </select>
                        </td>
                    </tr>
                    <!--运营商类型结束-->
                </tbody>
            </table>

            <table border="0" cellpadding="0" cellspacing="0" class="store-joinin ds-default-table">
                <thead>
                    <tr>
                        <th colspan="6">{$Think.lang.store_and_contact_info}</th>
                    </tr>
                </thead>
                <tbody>
                    <tr>
                        <th>{$Think.lang.company_name}：</th>
                        <td><input type="text" class="txt" name="company_name" id="company_name"></td>
                        <th>{$Think.lang.company_location}：</th>
                        <td><input type="hidden" name="company_address" id="company_address"></td>
                        <th>{$Think.lang.company_address}：</th>
                        <td colspan="3"><input type="text" class="txt w300" name="company_address_detail"></td>
                    </tr>
                    <tr>
                        <th>{$Think.lang.legal_person}：</th>
                        <td><input type="text" class="txt" name="legal_person"></td>
                        <th>{$Think.lang.legal_person_phone}：</th>
                        <td><input type="text" name="legal_person_phone" id="company_address"></td>
                        <th>{$Think.lang.contact_name}：</th>
                        <td colspan="3"><input type="text" class="txt w300" name="contacts_name"></td>
                    </tr>
                    <tr>
                        <th>{$Think.lang.contact_number}：</th>
                        <td><input type="text" class="txt" name="contacts_phone"></td>
                        <th>{$Think.lang.contact_phone}：</th>
                        <td><input type="text" class="txt" name="contact_legal_phone"></td>
                        <th>{$Think.lang.contact_qq}：</th>
                        <td><input type="text" class="txt" name="contact_qq"></td>

                    </tr>
                    <tr>
                        <th>{$Think.lang.e_mail}：</th>
                        <td><input type="text" class="txt" name="contacts_email"></td>
                    </tr>
                </tbody>
            </table>
            <table border="0" cellpadding="0" cellspacing="0" class="store-joinin ds-default-table">
                <thead>
                    <tr>
                        <th colspan="20">{$Think.lang.business_license_information}</th>
                    </tr>
                </thead>
                <tbody>
                    <tr>
                        <th class="w150">{$Think.lang.business_license_number}：</th>
                        <td><input type="text" class="txt" name="business_licence_number"></td>
                    </tr>
                    <tr>

                        <!-- <th class="w150">{$Think.lang.duty_paragraph}：</th>
                      <td><input type="text" class="txt" name="duty_paragraph" ></td></tr><tr> -->

                        <!-- <th class="w150">{$Think.lang.credit_code}：</th>
                      <td><input type="text" class="txt" name="credit_code" ></td></tr><tr> -->

                        <th>{$Think.lang.place_business_license}：</th>
                        <td><input type="hidden" name="business_licence_address" id="business_licence_address"></td>
                    </tr>
                    <tr>

                        <th>{$Think.lang.validity_business_license}：</th>
                        <td><input type="text" class="txt" name="business_licence_start" id="business_licence_start"> -
                            <input type="text" class="txt" name="business_licence_end" id="business_licence_end"></td>
                    </tr>
                    <tr>
                        <th>{$Think.lang.legal_scope_business}：</th>
                        <td colspan="20"><input type="text" class="txt w300" name="business_sphere"></td>
                    </tr>
                    <tr>
                        <th>
                            {$Think.lang.business_license}{$Think.lang.electronic_version}：</th>
                        <td>

                            <input type="hidden" name="business_licence_number_electronic" id="video_name">

                            <input type="file" hidefocus="true" name="video" id="videos"
                                data-action="{:url('Goodproject/ajax_videos')}">
                            <br>
                            <span style="color: #777;
    clear: both;
    margin-top: 10px;font-size: 0.8em;" class="block">{$Think.lang.upload_information2}</span></td>
                    </tr>
                </tbody>
            </table>


            <table border="0" cellpadding="0" cellspacing="0" class="store-joinin ds-default-table">
                <thead>
                    <tr>
                        <th colspan="2">{$Think.lang.store_alipay_info}：</th>
                    </tr>
                </thead>
                <tbody>
                    <tr>
                        <th>{$Think.lang.bank_account_name}：</th>
                        <td><input type="text" class="txt w300" name="settlement_bank_account_name"></td>
                    </tr>
                    <tr>
                        <th>{$Think.lang.bank_account_number}：</th>
                        <td><input type="text" class="txt w300" name="settlement_bank_account_number"></td>
                    </tr>

                    <tr>
                        <th>{$Think.lang.bank_name}：</th>
                        <td><input type="text" class="txt w300" name="settlement_bank_name"></td>
                    </tr>

                    <tr>
                        <th>{$Think.lang.bank_address}：</th>
                        <td><input type="text" class="txt w300" name="settlement_bank_address"></td>
                    </tr>
                </tbody>

            </table>


            <tfoot>
                <tr>
                    <td colspan="20">&nbsp;</td>
                </tr>
            </tfoot>
            </table>

            <div style="margin: 0 auto"><input class="btn join_submit" type="submit" value="{$Think.lang.ds_submit}" />
            </div>
        </form>
    </div>
</div>
<link rel="stylesheet" href="{$Think.PLUGINS_SITE_ROOT}/js/jquery.lightbox/css/lightbox.min.css">
<script src="{$Think.PLUGINS_SITE_ROOT}/js/jquery.lightbox/js/lightbox.min.js"></script>
<script type="text/javascript">
    $(function () {

        $(document).on('change', '#videos', function () {

            // $('#dataLoading').show();
            var files = document.getElementById('videos').files[0];

            var formData = new FormData();
            var obj = $(this);
            formData.append('file', files);
            var url = $(this).attr('data-action');
            $.ajax({
                //请求方式
                type: "POST",
                //请求地址
                url: url,
                data: formData,
                cache: false, //默认是true，但是一般不做缓存
                processData: false, //用于对data参数进行序列化处理，这里必须false；如果是true，就会将FormData转换为String类型
                contentType: false, //一些文件上传http协议的关系，自行百度，如果上传的有文件，那么只能设置为false
                //请求成功
                success: function (result) {

                    if (result.msg == 1) {
                        $('.vide').empty();
                        $('#dataLoading').hide();
                        layer.msg('上传成功');
                        $("#video_name").val(result.files_name);
                        // $("type[name='old_filename']").val(result.old_name);
                    } else {
                        obj.val('');
                        $('#dataLoading').hide();
                        layer.msg('文件信息错误,请重新上传');
                        return false;
                    }

                },
                //请求失败，包含具体的错误信息
                error: function (e) {
                    console.log(e.status);
                    console.log(e.responseText);
                }
            });

        });

        function nosubmit(c) {
            $(c).attr('disabled', 'true');
            $(c).css('background', '#eee');
        }

        function delnosubmit(c) {
            $(c).removeAttr('disabled');
            $(c).css('background', '');
        }
        // 用户名检测
        $('[name="settlement_bank_account_name"]').blur(function () {
            var val = $(this).val();
            if (!val) {
                nosubmit('.join_submit');
                layer.msg('银行开户名必须填写');
            } else {
                delnosubmit('.join_submit');
            }
            if (val.length <= 2) {
                nosubmit('.join_submit');
                layer.msg('银行开户名不能小于两个字符');
            } else {
                delnosubmit('.join_submit');
            }
            var pattern = /^[0-9]*$/;
            if (pattern.test(val)) {
                nosubmit('.join_submit');
                layer.msg('银行开户名不能为纯数字')
            } else {
                delnosubmit('.join_submit');
            }

        })
        // 银行卡位数
        $('[name="settlement_bank_account_number"]').blur(function () {
            var val = $(this).val();
            /**
             * 百度知道
             * 1、15位存折账号；
             2、16位卡号：有银联或VISA/MASTERCard标志的（包括普通一卡通、银联金卡/葵花卡、国际借记卡、IC卡、M+卡等）；
             3、12位老卡：较早开户的账户，4位城市区号+8位账号，如城市区号不足4位，首位以0补足；
             4、19位卡号：TOUCH卡（现已停止使用一卡通开通手机TOUCH卡）
             */
            if (val.length < 12 || val.length > 19) {
                nosubmit('.join_submit');
                layer.msg('请输入正确的银行卡号');
            } else {
                delnosubmit('.join_submit');
            }
        })
        // 联系人手机号
        $('[name="contact_legal_phone"]').blur(function () {
            var val = $(this).val();
            var pattern = /^(13[0-9]|14[5|7]|15[0|1|2|3|4|5|6|7|8|9]|18[0|1|2|3|5|6|7|8|9])\d{8}$/;
            if (!pattern.test(val)) {
                nosubmit('.join_submit');
                layer.msg('请输入正确的手机号')
            } else {
                delnosubmit('.join_submit');
            }
        })
        // 电子邮箱
        $('[name="contacts_email"]').blur(function () {
            var val = $(this).val();
            var pattern = /^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/;
            if (!pattern.test(val)) {
                nosubmit('.join_submit');
                layer.msg('邮箱格式不正确')
            } else {
                delnosubmit('.join_submit');
            }
        })
        $("#company_address").ds_region();
        $("#business_licence_address").ds_region();
        $("#bank_address").ds_region();
        $("#settlement_bank_address").ds_region();
        $('#end_time').datepicker({
            dateFormat: 'yy-mm-dd'
        });
        $('#business_licence_start').datepicker({
            dateFormat: 'yy-mm-dd'
        });
        $('#business_licence_end').datepicker({
            dateFormat: 'yy-mm-dd'
        });

        $.validator.addMethod("nostring", function (value, element, params) {
            var pattr = /^[0-9]+$/;
            if (pattr.test(value)) {
                // layer.msg('不能是数字')
                return false;
            }
            return true;
        }, '不能是数字');
        $("#joinin_form").validate({
            errorPlacement: function (error, element) {
                var error_td = element.parent('.item-text');
                error_td.append(error);
                element.parents('.item:first').addClass('error');
            },

            rules: {
                member_name: {
                    required: true,
                    minlength: 3,
                    maxlength: 15,
                    remote: {
                        url: HOMESITEURL + '/Login/check_member.html',
                        type: 'get',
                        data: {
                            user_name: function () {
                                return $('#member_name').val();
                            }
                        }
                    }
                },
                company_name: 'nostring',
                legal_person: 'nostring',
                company_address_detail: 'nostring',
                contacts_name: 'nostring',
                contacts_name: 'nostring'

            },
            messages: {
                member_name: {
                    required: '{$Think.lang.login_register_input_username}',
                    minlength: '{$Think.lang.login_register_username_range}',
                    maxlength: '{$Think.lang.login_register_username_range}',
                    remote: '{$Think.lang.login_register_username_exists}'
                },
                company_name: {
                    required: '企业名称不能为空',
                    nostring: '不能为数子',
                },
                legal_person: {
                    required: '法人姓名不能为空',
                }

            }
        });


        $(this).addClass('current').siblings().removeClass('current');
        var _index = $(this).index();
        var _form = $('div[dstype="editStoreContent"]').find('form');
        _form.hide();
        _form.eq(_index).show();

    });
</script>